<?php

$id = htmlentities(mysql_real_escape_string($_GET['id']));

$kegiatan = getKegiatanbyID($id);



$o .= '<a href="?page=monitoring&id='.$id.'"><i class="icon-plus"></i>monitoring</a><br>';

if ($kegiatan) {
	
	$o .= '
	<div class="row">
		<div class="span4">
			<table class="table table-striped">';
	
			$no = 1;
			
			foreach($kegiatan as $x) {
				
				$o .= '<tr>
							<td>Nama Kegiatan</td><td>: '.$x['nama_kegiatan'].'</td>
					  </tr>
					  <tr>
							<td>Kabupaten</td><td>: '.$x['kabupaten'].'</td>
					 </tr>
					 <tr>
							<td>Sektoral</td><td>: '.$x['sektoral'].'</td>
					</tr>
					<tr>
							<td>Pagu</td><td>: Rp. '.number_format($x['pagu']).'</td>
					</tr>
					<tr>
							<td>Longitude</td><td>: '.$x['long'].'</td>
					</tr>
					<tr>
							<td>Latitude</td><td>: '.$x['lat'].'</td>
					</tr>
					<tr>
							<td>Tahun</td><td>: '.$x['tahun'].'</td>
					</tr>
					<tr>
							<td>Operator</td><td>: '.$x['username'].'</td>
					</tr>';		
			}

			$o .= '</table>
			
			</div>';
			
			$js = '
		<script type="text/javascript">
		 function initialize() {
			var myLatlng = new google.maps.LatLng('.$x['lat'].','.$x['long'].');
			var myOptions = {
			  zoom: 14,
			  center: myLatlng,
			  mapTypeId: google.maps.MapTypeId.ROADMAP
			}
			var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
			
			var marker = new google.maps.Marker({
				position: myLatlng, 
				map: map,
				draggable : false
			});   
		  }
		</script>';

echo $js;

	$o .='
		 <div class="span8">
			<div id="map_canvas" style="width:100%; height:300px"></div>
		
		  </div></div><br><br>';
	
	$image = getKegiatanMonitor($id);
	
	if ($image) {
	
		$o .= '
			<h2>progress</h2>
			<table class="table table-striped table-bordered table-condensed">
				<tr>
					<td><center>No</td>
					<td><center>Progress</td>
					<td><center>Foto</td>
					<td><center>Tanggal Monitoring</td>
					<td colspan="2"><center>Aksi</td>
				</tr>
		
			  ';
		
		$no = 1;
		
		foreach($image as $x) {
			
			$o .= '<tr>
						<td><center>'.$no.'</td>
						<td><center>'.$x['progres'].' %</td>
						<td><center><a data-toggle="modal" href="#myModal'.$no.'"><img src="../file/thumbnail/'.$x['foto'].'"></a></td>
						<td><center>'.$x['tgl_monitoring'].'</td>
						<td><center><a href="?page=editmonitoring&id='.$x['idmonitoring'].'"><i class="icon-edit"></i>ubah</a></td>
						<td><center><a href="?page=detailkegiatan&action='.$x['idmonitoring'].'"><i class="icon-remove"></i>hapus</a></td>
				  </tr>';	  
			
			$o .= ' <div id="myModal'.$no.'" class="modal hide fade">
            <div class="modal-header">
              <button class="close" data-dismiss="modal">&times;</button>
           		<img src="../file/'.$x['foto'].'">
             <div class="modal-footer">
            
            </div>
          </div>';
			
			$no++;
			
		}
	
		$o .= '</table>';
	
	} else {

		$o .= '<div class="alert alert-error">
			  <center>Data monitor kosong</center>
			  </div>';
	} 
	
} else {

	$o .= '<div class="alert alert-error">
		  <center>Data kosong</center>
		  </div>';
} 

echo $o;
